<style>
    .footer-home{display: none}
    .place{font-weight: lighter;
    overflow: hidden;
    text-overflow: ellipsis;}
</style>
<link rel="stylesheet" type="text/css" href="resource/css/calendar.css?v=0.01">
<header>
    <a href="index.php" style="color: #fff">
        <i class="iconfont icon-xialalan-copy"></i>
    </a>
    <span class="search_icon  iconfont icon-search"></span>
    <form action="index.php" >
    <input type="hidden" name="act" value="hotel">
    <input type="hidden" name="op" value="index">
    <input class="fl search" type="text" name="keyword" value="<?php echo $output['get_data']['keyword']; ?>" placeholder="搜索酒店">
   </form>
</header>
<div class="contect margin_bot">

    <div id="checkinout">
        <div id="firstSelect" style="width:100%;">
            <div class="Date_lr" style="float:left;">
                <P>入住</p>
                <input id="startDate" type="text" value=""style="" readonly="readonly">
            </div>
            <div class="Date_lr" style="float:right;">
                <p>离店</p>
                <input id="endDate" type="text" value="" style="" readonly="readonly">
            </div>
            <span class="span21">共<span class="NumDate"><?php echo $output['hotel_time']['numdate'] ?></span>晚</span>
        </div>
    </div>
    <div class="mask_calendar">
        <div class="calendar"></div>
    </div>
    <form action="index.php" id="search">
        <input type="hidden" name="act" value="hotel">
        <input type="hidden" name="op" value="index">
        <input class="destina" type="text" name="keyword" value="<?php echo $output['get_data']['keyword']; ?>" placeholder="输入您需要查找的酒店名"/>
    </form>
    <div class="looking">
        <a class="looking_a"  id="search_but">查找酒店</a>
    </div>
    <div class="select_item flex_display">
        <!--新的下拉标签-->

        <a class="flex-1  <?php echo isset($_GET['price'])?'color_blue':'';?> haha" >
            <?php if(isset($_GET['price'])): ?>
                    <?php if($_GET['price']=='asc'): ?>
                    价格从低到高
                    <?php elseif($_GET['price']=='desc'): ?>
                    价格从高到低
                    <?php else: ?>
                    默认排序
                    <?php endif; ?>
            <?php else: ?>
            默认排序
            <?php endif; ?>
            <i class="iconfont icon-xialalan"></i>
        </a>

                    <ul id="price" >
                        <li id="">默认排序</li>
                        <li id="asc">价格从低到高</li>
                        <li id="desc">价格从高到低</li>
                       <!-- <li>销量从低到高</li>
                        <li>销量从高到低</li>-->
                    </ul>

                    <a class="flex-1  <?php echo isset($_GET['area'])?'color_blue':''; ?> haha" >
                        <?php if(isset($_GET['area'])): ?>
                            <?php if($_GET['area']>0): ?>
                            <?php foreach($output['area_arr'] as$k=>$v): ?>
                          <span style="<?php if($_GET['area']!=$v['ht_area_id']){echo 'display: none;'; }; ?>"><?php echo $v['name']; ?></span>
                             <?php endforeach ?>
                             <?php else: ?>
                                全部地区
                             <?php endif; ?>
                        <?php else: ?>
                            地区筛选
                        <?php endif; ?>
                        <i class="iconfont icon-xialalan"></i>
                    </a>
                    <ul id="area">
                        <li id="">全部地区</li>
                        <?php foreach($output['area_arr'] as$k=>$v): ?>
                        <li id="<?php echo $v['ht_area_id']; ?>"><?php echo $v['name']; ?></li>
                        <?php endforeach ?>
                    </ul>

                    <a class="flex-1 <?php echo isset($_GET['cate_id'])?'color_blue':''; ?> haha" >
                        <?php if(isset($_GET['cate_id'])): ?>
                            <?php if($_GET['cate_id']>0): ?>
                                <?php foreach($output['cate'] as$k=>$v): ?>
                                    <span style="<?php if($_GET['cate_id']!=$v['tc_id']){echo 'display: none;'; }; ?>"><?php echo $v['tc_name']; ?></span>
                                <?php endforeach ?>
                            <?php else: ?>
                                全部分类
                            <?php endif; ?>
                        <?php else: ?>
                            全部分类
                        <?php endif; ?>
                        <i class="iconfont icon-xialalan"></i>
                    </a>
                   <ul id="cate_id">
                       <li id="">全部分类</li>
                       <?php foreach($output['cate'] as$k=>$v): ?>
                      <li id="<?php echo $v['tc_id']; ?>"><?php echo $v['tc_name']; ?></li>
                      <?php endforeach ?>
                    </ul>

        <!--下拉标签结束-->
    </div>
    <div class="select_list">
        <?php  if($output['data']){?>
            <?php  foreach($output['data'] as $key =>$value){?>
                <a href="index.php?act=hotel&op=hotel_info&hotel_id=<?php echo $value['id']; ?>">
           <div class="list flex_display">
            <div class="list_img flex-0"><img src="<?php echo $value['hotel_thumb']; ?>"></div>
            <div class="list_txt flex-1">
                <span class="list_title"><?php echo $value['hotel_name']; ?></span>
                <div class="score"><?php echo $value['hotel_point'];?></div>

                <div class="place p-1"><?php echo $value['ht_full_addr'];?></div>
                <div class="price ">

                    <span ><i class="place connect iconfont icon-weizhi"></i>距离<?php echo $value['distance']; ?></span>


                    <span class="fr"><i class="red iconfont icon-renminbi "><?php echo $value['ht_market_price'];?></i>起</span></div>
            </div>
        </div>
                    </a>
            <?php }?>
        <?php } ?>
    </div>

</div>
<!--加载更多-->
<div class="load" style="text-align: center;display: none;">
    <div class="loading" style="text-align: center;">正在加载中....</div>
</div>
<script type="text/javascript" src="resource/js/date.js?v=1.51"></script>
<script>
    $(function(){
        $('#firstSelect').on('click',function () {
            $('.mask_calendar').show();
        });
        $('.mask_calendar').on('click',function (e) {
            if(e.target.className == "mask_calendar"){
                $('.calendar').slideUp(200);
                $('.mask_calendar').fadeOut(200);
            }
        })
        $('#firstSelect').calendarSwitch({
            selectors : {
                sections : ".calendar"
            },
            index : 6,      //展示的月份个数
            animateFunction : "slideToggle",        //动画效果
            controlDay:true,//知否控制在daysnumber天之内，这个数值的设置前提是总显示天数大于90天
            daysnumber : "130",     //控制天数
            comeColor : "#3FACEF",       //入住颜色
            outColor : "#3FACEF",      //离店颜色
            comeoutColor : "#C1DEF0",        //入住和离店之间的颜色
            callback :function(){//回调函数
                $('.mask_calendar').fadeOut(200);
                var startDate = $('#startDate').val();  //入住的天数
                var endDate = $('#endDate').val();      //离店的天数
                var NumDate = $('.NumDate').text();    //共多少晚
                var startDate = startDate.replace("年0","");//替换显示
                var startDate = startDate.replace('年1','');
                $('#startDate').val(startDate);
                console.log(startDate);
                console.log(endDate);
                console.log(NumDate);
                //下面做ajax请求
                //show_loading();
                $.post("index.php?act=hotel&op=edit_check_time",{startdate:startDate, enddate:endDate, numdate:NumDate},function(data){
                 /*if(data.res=='true'){
                 alert('修改成功')
                 } else {
                 alert('修改失败');
                 }*/
                 },'json');
            }  ,
            comfireBtn:'.comfire'//确定按钮的class或者id
        });
        var b=new Date();
        var ye=b.getFullYear();
        var mo=b.getMonth()+1;
        mo = mo<10?"0"+mo:mo;
        var da=b.getDate();
        da = da<10?"0"+da:da;
        $('#startDate').val("<?php echo $output['hotel_time']['startdate']; ?>");
        b=new Date(b.getTime()+24*3600*1000);
        var ye=b.getFullYear();
        var mo=b.getMonth()+1;
        mo = mo<10?"0"+mo:mo;
        var da=b.getDate();
        da = da<10?"0"+da:da;
        $('#endDate').val("<?php echo  $output['hotel_time']['enddate']; ?>");
    });
    $(function(){
        $("#search_but").click(function(){
            //提交搜索
            $("#search").submit();
        });
    })

    //ajax加载分页

    var allNum = <?php echo $output['TotalNum']; ?>,
        allPage = <?php echo $output['TotalPage']; ?>,
        curPage = 1;

    var is_scroll = false;
    $(window).scroll(function () {
        is_scroll = true;
        //已经滚动到上面的页面高度
        var scrollTop = $(this).scrollTop();
        //页面高度
        var scrollHeight = $(document).height();
        //浏览器窗口高度
        var windowHeight = $(this).height();
        //此处是滚动条到底部时候触发的事件，在这里写要加载的数据，或者是拉动滚动条的操作
        if (scrollTop + windowHeight == scrollHeight) {
            $('.load').show();
            loadpage();
        }
    });
    //ajax加载数据
    function loadpage() {
        if(!is_scroll){
            return;
        }
        if (curPage < allPage) {
            curPage += 1;
        } else {
            $('.load').text('没有更多内容了').show();
            return;
        }
        $.get(location.href, {isajax:1,curpage:curPage},function(data){
            if(data){
                $(".select_list").append(data);
                $('.load').hide();
            }
        });
    }

    $(".sele").change(function(){
        var name = $(this).attr('name')
        var val = $(this).val();
        window.location.href='index.php?act=hotel&'+name+'='+val;
        //alert($(this).val());
        //alert($(this).attr('name'));
    });

//下拉选项
    $(".select_item a").click(function () {
        $(this).addClass("color_blue").siblings().removeClass("color_blue");
        $(this).next("ul").slideToggle();
        $(this).next("ul").siblings("ul").css("display","none");

    });

    //文本传值
    $(".select_item li").click(function () {
        var i='<i class="iconfont icon-xialalan"></i>';
        $(this).parent().prev().html($(this).html()+i);
        $(this).parent("ul").slideUp();
        var name = $(this).parents('ul').attr('id');
        var val = $(this).attr('id');
        window.location.href='index.php?act=hotel&'+name+'='+val;
       // alert($(this).parents('ul').attr('id'));
    });

</script>
<?php if ($_SESSION['pos']['js'] == false /*&& strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') == false*/): ?>
    <script src="//webapi.amap.com/maps?v=1.4.3&key=e5c438490a60083b210b012342ff9339"></script>
    <script src="//cache.amap.com/lbs/static/es5.min.js"></script>
    <script>
        var mapObj = new AMap.Map('iCenter');
        var  geolocation;
        mapObj.plugin('AMap.Geolocation', function () {
            geolocation = new AMap.Geolocation({
                enableHighAccuracy: true,//是否使用高精度定位，默认:true
                timeout: 100000,          //超过10秒后停止定位，默认：无穷大
                maximumAge: 10000,           //定位结果缓存0毫秒，默认：0
                convert: true           //自动偏移坐标，偏移后的坐标为高德坐标，默认：true
            });

            geolocation.getCurrentPosition();
            mapObj.addControl(geolocation);
            AMap.event.addListener(geolocation, 'complete', onComplete); //返回定位信息
            AMap.event.addListener(geolocation, 'error', onError); //返回定位出错信息
        });

        //获取经纬度
        function onComplete(data) {
            console.log(data.position.getLng());
            console.log(data.position.getLat());
            var lng = data.position.getLng();//经度
            var lat = data.position.getLat();//纬度
            $.getJSON('index.php?act=location&op=ajax',{lng:lng,lat:lat},function(json){
                /*json.reloads && json.city && popAlert('定位到'+json.city+'，将为您切换到'+json.city, function () {
                 location.reload();
                 }, 0);*/
                json.reloads && json.city && location.reload();
            });
        }
        function onError(data) {
            console.log(data);
            //popAlert('您禁用了定位' + e.message);
        }
    </script>
<?php endif; ?>